package cn.shenzz.suixiang.array.leetcode_27;

class Solution {
    public static void main(String[] args) {
        int[] nums = {0, 1, 2, 2, 3, 0, 4, 2};
        int target = 2;
        System.out.println(removeElement(nums, target));
    }

    public static int removeElement(int[] nums, int val) {
        int digit = 0, n = nums.length;
        for (int i = 0; i < n; ++i) {
            if (nums[i] != val) {
                nums[digit++] = nums[i];
            }
        }
        return digit;
    }
}